package com.config;

import com.component.MyLocaleResolver;
import com.interceptor.MyInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

//@Configuration
public class LoginConfig implements WebMvcConfigurer {
    @Bean
    public MyInterceptor myInterceptor() {
        return new MyInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration registration = registry.addInterceptor(myInterceptor());
//        registration.addPathPatterns("/bank/**");                     //所有路径都被拦截

        registration.excludePathPatterns("/**/login",
                "/**/dologin",
                "/**/index",
                "/images/*",
                "/login",
                "/back/*",
                "/calendar/*",
                "/cart/*",
                "/css/*",             //css静态资源
                "/files/*",
                "/js/*"

        );//添加不拦截路径
    }

    @Bean
    public LocaleResolver localeResolver() {
        return new MyLocaleResolver();
    }
}
